/**
 * @file wa_screen.c
 *
 */

 /*********************
  *      INCLUDES
  *********************/
#include "wa_conf.h"
#if (USE_WA_WIN != 0)&&(USE_WA_SCREEN != 0)
#include "wa_screen.h"
#include "wa_anim.h"
#include "wa_anim_timeline.h"
#include "wa_pid.h"
#include "wa_input.h"
#include "wa_screen_erase.h"

/*********************
*      DEFINES
*********************/
#if USE_WA_ANIM != 0
#define WA_SCREEN_ANIM_SWITCH_MAX		4
#endif
/**********************
*      TYPEDEFS
**********************/

typedef struct
{
	wa_screen_obj** screen;
	uint32_t screen_cnt;
	wa_screen_obj* src;
	wa_screen_obj* dst;
#if USE_WA_ANIM != 0
	wa_screen_switch_type current_type;
	wa_anim* an_switch[WA_SCREEN_ANIM_SWITCH_MAX];
	wa_anim_timeline_dsc ad_switch[WA_SCREEN_ANIM_SWITCH_MAX];
	uint8_t an_switch_cnt;
	wa_anim_timeline at_swicth;
	uint8_t an_current;
	wa_screen_erase* scr_erase;
	int sx;
	int sy;
	int sw;
	int sh;
	wa_result se;
	wa_result ses;
	int dx;
	int dy;
	int dw;
	int dh;
	wa_result de;
	wa_result des;
	wa_result pid;
	wa_result input;
#endif
}wa_screen_switch_context;

typedef struct
{
	wa_screen_switch_type type;
	wa_result src_top_before_switch;
	wa_result dst_create_before_switch;
	wa_result src_del_before_switch;
	uint32_t dst_create_in_switch;
	uint32_t src_del_in_switch;
	wa_result dst_create_after_switch;
	wa_result src_del_after_switch;
	void (*set_value)(void);
	void (*exec_cb)(uint8_t anim_num, uint8_t anim_array, int32_t value);
	uint8_t anim_cnt;
}wa_screen_switch_cfg;

/**********************
*  STATIC PROTOTYPES
**********************/
static wa_screen_obj* wa_screen_find_from_id(uint32_t id);
#if USE_WA_ANIM != 0
static wa_result wa_screen_switch_dst_need_create_before_switch(wa_screen_switch_type type);
static wa_result wa_screen_switch_src_need_del_before_switch(wa_screen_switch_type type);
static wa_result wa_screen_switch_dst_need_create_after_switch(wa_screen_switch_type type);
static wa_result wa_screen_switch_src_need_del_after_switch(wa_screen_switch_type type);
static wa_result wa_screen_src_need_to_top_before_switch(wa_screen_switch_type type);
static void wa_screen_dst_prepare_before_anim(void);
static void wa_screen_set_anim_timeline(wa_screen_switch_type type, uint32_t time_long);
static void wa_screen_save_hmi_before_swtich(void);
static void wa_screen_recover_hmi_after_swtich(void);
static void wa_screen_dst_prepare_before_anim(void);
static void wa_screen_dst_do_after_anim(void);
static void wa_screen_src_prepare_before_anim(void);

static void blinds_hor_set_value(void);
static void blinds_hor_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void blinds_ver_set_value(void);
static void blinds_ver_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void boxs_hor_set_value(void);
static void boxs_hor_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void boxs_ver_set_value(void);
static void boxs_ver_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void top_move_enter_set_value(void);
static void top_move_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void bottom_move_enter_set_value(void);
static void bottom_move_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void left_move_enter_set_value(void);
static void left_move_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void right_move_enter_set_value(void);
static void right_move_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void top_move_quit_set_value(void);
static void top_move_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void bottom_move_quit_set_value(void);
static void bottom_move_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void left_move_quit_set_value(void);
static void left_move_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void right_move_quit_set_value(void);
static void right_move_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void top_size_enter_set_value(void);
static void top_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void left_size_enter_set_value(void);
static void left_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void top_left_size_enter_set_value(void);
static void top_left_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void top_size_quit_set_value(void);
static void top_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void left_size_quit_set_value(void);
static void left_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void top_left_size_quit_set_value(void);
static void top_left_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void bottom_size_enter_set_value(void);
static void bottom_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void right_size_enter_set_value(void);
static void right_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void bottom_size_quit_set_value(void);
static void bottom_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void right_size_quit_set_value(void);
static void right_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void top_right_size_enter_set_value(void);
static void top_right_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void bottom_left_size_enter_set_value(void);
static void bottom_left_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void bottom_right_size_enter_set_value(void);
static void bottom_right_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void top_right_size_quit_set_value(void);
static void top_right_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void bottom_left_size_quit_set_value(void);
static void bottom_left_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void bottom_right_size_quit_set_value(void);
static void bottom_right_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void center_size_enter_set_value(void);
static void center_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void center_size_quit_set_value(void);
static void center_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void center_hv_size_enter_set_value(void);
static void center_hv_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void center_vh_size_enter_set_value(void);
static void center_vh_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void center_hv_size_quit_set_value(void);
static void center_hv_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void center_vh_size_quit_set_value(void);
static void center_vh_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void top_together_set_value(void);
static void top_together_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void bottom_together_set_value(void);
static void bottom_together_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void left_together_set_value(void);
static void left_together_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);
static void right_together_set_value(void);
static void right_together_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value);

#endif

/**********************
 *  STATIC VARIABLES
 **********************/
static wa_screen_switch_context screen_context;
#if USE_WA_ANIM != 0
static const wa_screen_switch_cfg screen_switch_cfg_map[] =
{
	{
		.type = WA_SCREEN_SWITCH_TYPE_NOANIM,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_nok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_nok,
		.set_value = NULL,
		.exec_cb = NULL,
		.anim_cnt = 0,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_BLINDS_HOR,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_nok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x01,
		.src_del_in_switch = 0x01,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_nok,
		.set_value = blinds_hor_set_value,
		.exec_cb = blinds_hor_exec_cb,
		.anim_cnt = 2,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_BLINDS_VER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_nok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x01,
		.src_del_in_switch = 0x01,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_nok,
		.set_value = blinds_ver_set_value,
		.exec_cb = blinds_ver_exec_cb,
		.anim_cnt = 2,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_BOXS_HOR,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_nok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x01,
		.src_del_in_switch = 0x01,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_nok,
		.set_value = boxs_hor_set_value,
		.exec_cb = boxs_hor_exec_cb,
		.anim_cnt = 2,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_BOXS_VER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_nok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x01,
		.src_del_in_switch = 0x01,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_nok,
		.set_value = boxs_ver_set_value,
		.exec_cb = boxs_ver_exec_cb,
		.anim_cnt = 2,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_TOP_MOVE_ENTER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = top_move_enter_set_value,
		.exec_cb = top_move_enter_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_BOTTOM_MOVE_ENTER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = bottom_move_enter_set_value,
		.exec_cb = bottom_move_enter_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_LEFT_MOVE_ENTER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = left_move_enter_set_value,
		.exec_cb = left_move_enter_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_RIGHT_MOVE_ENTER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = right_move_enter_set_value,
		.exec_cb = right_move_enter_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_TOP_MOVE_QUIT,
		.src_top_before_switch = wa_ok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = top_move_quit_set_value,
		.exec_cb = top_move_quit_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_BOTTOM_MOVE_QUIT,
		.src_top_before_switch = wa_ok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = bottom_move_quit_set_value,
		.exec_cb = bottom_move_quit_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_LEFT_MOVE_QUIT,
		.src_top_before_switch = wa_ok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = left_move_quit_set_value,
		.exec_cb = left_move_quit_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_RIGHT_MOVE_QUIT,
		.src_top_before_switch = wa_ok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = right_move_quit_set_value,
		.exec_cb = right_move_quit_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_TOP_SIZE_ENTER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = top_size_enter_set_value,
		.exec_cb = top_size_enter_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_LEFT_SIZE_ENTER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = left_size_enter_set_value,
		.exec_cb = left_size_enter_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_TOP_LEFT_SIZE_ENTER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = top_left_size_enter_set_value,
		.exec_cb = top_left_size_enter_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_TOP_SIZE_QUIT,
		.src_top_before_switch = wa_ok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = top_size_quit_set_value,
		.exec_cb = top_size_quit_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_LEFT_SIZE_QUIT,
		.src_top_before_switch = wa_ok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = left_size_quit_set_value,
		.exec_cb = left_size_quit_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_TOP_LEFT_SIZE_QUIT,
		.src_top_before_switch = wa_ok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = top_left_size_quit_set_value,
		.exec_cb = top_left_size_quit_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_BOTTOM_SIZE_ENTER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = bottom_size_enter_set_value,
		.exec_cb = bottom_size_enter_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_RIGHT_SIZE_ENTER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = right_size_enter_set_value,
		.exec_cb = right_size_enter_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_BOTTOM_SIZE_QUIT,
		.src_top_before_switch = wa_ok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = bottom_size_quit_set_value,
		.exec_cb = bottom_size_quit_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_RIGHT_SIZE_QUIT,
		.src_top_before_switch = wa_ok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = right_size_quit_set_value,
		.exec_cb = right_size_quit_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_TOP_RIGHT_SIZE_ENTER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = top_right_size_enter_set_value,
		.exec_cb = top_right_size_enter_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_BOTTOM_LEFT_SIZE_ENTER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = bottom_left_size_enter_set_value,
		.exec_cb = bottom_left_size_enter_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_BOTTOM_RIGHT_SIZE_ENTER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = bottom_right_size_enter_set_value,
		.exec_cb = bottom_right_size_enter_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_TOP_RIGHT_SIZE_QUIT,
		.src_top_before_switch = wa_ok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = top_right_size_quit_set_value,
		.exec_cb = top_right_size_quit_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_BOTTOM_LEFT_SIZE_QUIT,
		.src_top_before_switch = wa_ok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = bottom_left_size_quit_set_value,
		.exec_cb = bottom_left_size_quit_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_BOTTOM_RIGHT_SIZE_QUIT,
		.src_top_before_switch = wa_ok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = bottom_right_size_quit_set_value,
		.exec_cb = bottom_right_size_quit_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_CENTER_SIZE_ENTER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = center_size_enter_set_value,
		.exec_cb = center_size_enter_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_CENTER_SIZE_QUIT,
		.src_top_before_switch = wa_ok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = center_size_quit_set_value,
		.exec_cb = center_size_quit_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_CENTER_HV_SIZE_ENTER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = center_hv_size_enter_set_value,
		.exec_cb = center_hv_size_enter_exec_cb,
		.anim_cnt = 2,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_CENTER_VH_SIZE_ENTER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = center_vh_size_enter_set_value,
		.exec_cb = center_vh_size_enter_exec_cb,
		.anim_cnt = 2,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_CENTER_HV_SIZE_QUIT,
		.src_top_before_switch = wa_ok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = center_hv_size_quit_set_value,
		.exec_cb = center_hv_size_quit_exec_cb,
		.anim_cnt = 2,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_CENTER_VH_SIZE_QUIT,
		.src_top_before_switch = wa_ok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = center_vh_size_quit_set_value,
		.exec_cb = center_vh_size_quit_exec_cb,
		.anim_cnt = 2,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_TOP_TOGETHER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = top_together_set_value,
		.exec_cb = top_together_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_BOTTOM_TOGETHER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = bottom_together_set_value,
		.exec_cb = bottom_together_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_LEFT_TOGETHER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = left_together_set_value,
		.exec_cb = left_together_exec_cb,
		.anim_cnt = 1,
	},
	{
		.type = WA_SCREEN_SWITCH_TYPE_RIGHT_TOGETHER,
		.src_top_before_switch = wa_nok,
		.dst_create_before_switch = wa_ok,
		.src_del_before_switch = wa_nok,
		.dst_create_in_switch = 0x00,
		.src_del_in_switch = 0x00,
		.dst_create_after_switch = wa_nok,
		.src_del_after_switch = wa_ok,
		.set_value = right_together_set_value,
		.exec_cb = right_together_exec_cb,
		.anim_cnt = 1,
	},
};
#endif
/**********************
*      MACROS
**********************/

/**********************
*   GLOBAL FUNCTIONS
**********************/

/**
* screen module init
*/
void wa_screen_module_init(void)
{
	wa_screen_switch_context* sm = &screen_context;
	sm->screen = NULL;
	sm->screen_cnt = 0;
	sm->src = NULL;
	sm->dst = NULL;
#if USE_WA_ANIM != 0
	sm->scr_erase = wa_screen_erase_create();
	wa_screen_erase_set_area(sm->scr_erase, 0, 0, WA_LCD_W, WA_LCD_H);
	sm->an_switch_cnt = 0;
	sm->an_current = 0;
#endif
}

/**
* add a screen to screen manager
* @param scr
*/
void wa_screen_add(wa_screen_obj* scr)
{
	wa_screen_switch_context* sm = &screen_context;
	if (wa_screen_find_from_id(scr->id) != NULL)
	{
		return;
	}
	if (sm->screen == NULL)
	{
		sm->screen = wa_malloc(sizeof(wa_screen_obj*));
		sm->screen[0] = scr;
		sm->screen_cnt = 1;
	}
	else
	{
		wa_screen_obj** p;
		sm->screen_cnt++;
		p = wa_malloc(sizeof(wa_screen_obj*) * sm->screen_cnt);
		memcpy(p, sm->screen, sizeof(wa_screen_obj*) * (sm->screen_cnt - 1));
		wa_free(sm->screen);
		sm->screen = p;
		sm->screen[sm->screen_cnt - 1] = scr;
	}
}

/**
* goto homepage
* @param id
*/
void wa_screen_goto_homepage(uint32_t id)
{
	wa_screen_switch_context* sm = &screen_context;
	sm->src = wa_screen_find_from_id(id);
	if (sm->src == NULL)
	{
		return;
	}
	if (sm->src->create != NULL)
	{
		sm->src->create();
	}
}
/**
* switch screen
* @param dst_id
* @param type
*/
void wa_screen_switch(uint32_t dst_id, wa_screen_switch_type type, uint32_t time_long, wa_result src_edge, wa_result dst_edge)
{
	wa_screen_switch_context* sm = &screen_context;
	sm->dst = wa_screen_find_from_id(dst_id);
	if (sm->dst == NULL)
	{
		return;
	}
	if (type == WA_SCREEN_SWITCH_TYPE_NOANIM)
	{
		if (sm->dst->create != NULL)
		{
			sm->dst->create();
		}
		if (sm->src->del != NULL)
		{
			sm->src->del();
		}
		screen_context.src = screen_context.dst;
		return;
	}
#if USE_WA_ANIM != 0
	screen_context.des = dst_edge;
	screen_context.ses = src_edge;
	sm->current_type = type;
	if (wa_screen_switch_dst_need_create_before_switch(type) == wa_ok)
	{
		if (sm->dst->create != NULL)
		{
			sm->dst->create();
		}
		wa_screen_dst_prepare_before_anim();
	}
	if (wa_screen_src_need_to_top_before_switch(type) == wa_ok)
	{
		wa_obj_to_top((wa_obj*)sm->src->win);
	}
	if (wa_screen_switch_src_need_del_before_switch(type) == wa_ok)
	{
		if (sm->src->del != NULL)
		{
			sm->src->del();
		}
	}
	wa_screen_src_prepare_before_anim();
	wa_screen_save_hmi_before_swtich();
	wa_screen_set_anim_timeline(type, time_long);
	sm->an_current = 0;
	wa_anim_timeline_start(&screen_context.at_swicth);
#endif
}

/**********************
 *   STATIC FUNCTIONS
 **********************/
 /**
 * find screen from id
 * @param id
 * @return screen
 */
static wa_screen_obj* wa_screen_find_from_id(uint32_t id)
{
	uint32_t i;
	wa_screen_switch_context* sm = &screen_context;
	wa_screen_obj* scr = NULL;

	for (i = 0; i < sm->screen_cnt; i++)
	{
		if (sm->screen[i]->id == id)
		{
			scr = sm->screen[i];
			break;
		}
	}
	return scr;
}

#if USE_WA_ANIM != 0
/**
* src screen is need to top before switch
* @param type
* @return result
*/
static wa_result wa_screen_src_need_to_top_before_switch(wa_screen_switch_type type)
{
	uint8_t size;
	uint8_t i;
	size = sizeof(screen_switch_cfg_map) / sizeof(wa_screen_switch_cfg);
	for (i = 0; i < size; i++)
	{
		if (screen_switch_cfg_map[i].type == type)
		{
			return screen_switch_cfg_map[i].src_top_before_switch;
		}
	}
	return wa_nok;
}

/**
* dst screen is need to create before switch
* @param type
* @return result
*/
static wa_result wa_screen_switch_dst_need_create_before_switch(wa_screen_switch_type type)
{
	uint8_t size;
	uint8_t i;
	size = sizeof(screen_switch_cfg_map) / sizeof(wa_screen_switch_cfg);
	for (i = 0; i < size; i++)
	{
		if (screen_switch_cfg_map[i].type == type)
		{
			return screen_switch_cfg_map[i].dst_create_before_switch;
		}
	}
	return wa_nok;
}

/**
* src screen is need to del before switch
* @param type
* @return result
*/
static wa_result wa_screen_switch_src_need_del_before_switch(wa_screen_switch_type type)
{
	uint8_t size;
	uint8_t i;
	size = sizeof(screen_switch_cfg_map) / sizeof(wa_screen_switch_cfg);
	for (i = 0; i < size; i++)
	{
		if (screen_switch_cfg_map[i].type == type)
		{
			return screen_switch_cfg_map[i].src_del_before_switch;
		}
	}
	return wa_nok;
}

/**
* dst screen is need to create after switch
* @param type
* @return result
*/
static wa_result wa_screen_switch_dst_need_create_after_switch(wa_screen_switch_type type)
{
	uint8_t size;
	uint8_t i;
	size = sizeof(screen_switch_cfg_map) / sizeof(wa_screen_switch_cfg);
	for (i = 0; i < size; i++)
	{
		if (screen_switch_cfg_map[i].type == type)
		{
			return screen_switch_cfg_map[i].dst_create_after_switch;
		}
	}
	return wa_nok;
}

/**
* src screen is need to del after switch
* @param type
* @return result
*/
static wa_result wa_screen_switch_src_need_del_after_switch(wa_screen_switch_type type)
{
	uint8_t size;
	uint8_t i;
	size = sizeof(screen_switch_cfg_map) / sizeof(wa_screen_switch_cfg);
	for (i = 0; i < size; i++)
	{
		if (screen_switch_cfg_map[i].type == type)
		{
			return screen_switch_cfg_map[i].src_del_after_switch;
		}
	}
	return wa_nok;
}

 /**
 * save param of dst before anim
 */
static void wa_screen_dst_prepare_before_anim(void)
{
	wa_win_ext* ext;
	screen_context.dx = screen_context.dst->win->rect.x1;
	screen_context.dy = screen_context.dst->win->rect.y1;
	screen_context.dw = wa_obj_get_width(screen_context.dst->win);
	screen_context.dh = wa_obj_get_height(screen_context.dst->win);
	ext = wa_obj_get_ext_attr(screen_context.dst->win);
	screen_context.de = ext->edge_show;
	if (screen_context.des == wa_ok)
	{
		wa_win_set_edge_show(screen_context.dst->win, wa_ok);
	}
}

/**
* recover of dst after anim
*/
static void wa_screen_dst_do_after_anim(void)
{
	wa_win_set_edge_show(screen_context.dst->win, screen_context.de);
}

/**
 * save param of src before anim
 */
static void wa_screen_src_prepare_before_anim(void)
{
	wa_win_ext* ext;
	screen_context.sx = screen_context.src->win->rect.x1;
	screen_context.sy = screen_context.src->win->rect.y1;
	screen_context.sw = wa_obj_get_width(screen_context.src->win);
	screen_context.sh = wa_obj_get_height(screen_context.src->win);
	ext = wa_obj_get_ext_attr(screen_context.src->win);
	screen_context.se = ext->edge_show;
	if (screen_context.ses == wa_ok)
	{
		wa_win_set_edge_show(screen_context.src->win, wa_ok);
	}
}

/**
* dst screen is need to create in switch
* @param type
* @param anim num
* @return result
*/
static wa_result wa_screen_switch_dst_need_create_in_switch(wa_screen_switch_type type, uint8_t anim_num)
{
	uint8_t size;
	uint8_t i;
	size = sizeof(screen_switch_cfg_map) / sizeof(wa_screen_switch_cfg);
	for (i = 0; i < size; i++)
	{
		if (screen_switch_cfg_map[i].type == type)
		{
			if ((screen_switch_cfg_map[i].dst_create_in_switch & (1 << anim_num)) != 0x00)
			{
				return wa_ok;
			}
		}
	}
	return wa_nok;
}

/**
* src screen is need to del in switch
* @param type
* @param anim num
* @return result
*/
static wa_result wa_screen_switch_src_need_del_in_switch(wa_screen_switch_type type, uint8_t anim_num)
{
	uint8_t size;
	uint8_t i;
	size = sizeof(screen_switch_cfg_map) / sizeof(wa_screen_switch_cfg);
	for (i = 0; i < size; i++)
	{
		if (screen_switch_cfg_map[i].type == type)
		{
			if ((screen_switch_cfg_map[i].src_del_in_switch & (1 << anim_num)) != 0x00)
			{
				return wa_ok;
			}
		}
	}
	return wa_nok;
}

/**
* get the anim cnt of switch
* @param type
* @return anim cnt
*/
static uint8_t wa_screen_get_anim_cnt(wa_screen_switch_type type)
{
	uint8_t size;
	uint8_t i;
	size = sizeof(screen_switch_cfg_map) / sizeof(wa_screen_switch_cfg);
	for (i = 0; i < size; i++)
	{
		if (screen_switch_cfg_map[i].type == type)
		{
			return screen_switch_cfg_map[i].anim_cnt;
		}
	}
	return 0;
}

/**
* switch set anim value
* @param type
*/
static void wa_screen_switch_set_anim_value(wa_screen_switch_type type)
{
	uint8_t size;
	uint8_t i;
	size = sizeof(screen_switch_cfg_map) / sizeof(wa_screen_switch_cfg);
	for (i = 0; i < size; i++)
	{
		if (screen_switch_cfg_map[i].type == type)
		{
			if (screen_switch_cfg_map[i].set_value != NULL)
			{
				screen_switch_cfg_map[i].set_value();
			}
			screen_context.an_switch_cnt = screen_switch_cfg_map[i].anim_cnt;
			break;
		}
	}
}

/**
*switch anim exec callback
*/
static void wa_screen_switch_exec_cb(void* var, int32_t value)
{
	uint8_t size;
	uint8_t i;
	uint8_t anim_array;
	wa_anim* anim = (wa_anim*)var;
	size = sizeof(screen_switch_cfg_map) / sizeof(wa_screen_switch_cfg);
	for (i = 0; i < screen_context.an_switch_cnt; i++)
	{
		if (anim == screen_context.an_switch[i])
		{
			anim_array = i;
			break;
		}
	}
	if (i >= screen_context.an_switch_cnt)
	{
		return;
	}
	for (i = 0; i < size; i++)
	{
		if (screen_switch_cfg_map[i].type == screen_context.current_type)
		{
			if (screen_switch_cfg_map[i].exec_cb != NULL)
			{
				screen_switch_cfg_map[i].exec_cb(screen_context.an_current, anim_array, value);
			}
			break;
		}
	}
}

/**
*switch anim finish callback
*/
static void wa_screen_switch_finish_cb(void* type)
{
	uint8_t i;
	wa_screen_switch_type t = screen_context.current_type;
	if (screen_context.an_current == (screen_context.an_switch_cnt - 1))
	{
		if (wa_screen_switch_src_need_del_after_switch(t) == wa_ok)
		{
			screen_context.src->del();
		}
		if (wa_screen_switch_dst_need_create_after_switch(t) == wa_ok)
		{
			screen_context.dst->create();
		}
		wa_screen_dst_do_after_anim();
		wa_screen_recover_hmi_after_swtich();
		screen_context.an_current = 0;
		screen_context.src = screen_context.dst;
		for (i = 0; i < screen_context.an_switch_cnt; i++)
		{
			wa_free(screen_context.an_switch[i]);
		}
	}
	else
	{
		if (wa_screen_switch_src_need_del_in_switch(t, screen_context.an_current) == wa_ok)
		{
			screen_context.src->del();
		}
		if (wa_screen_switch_dst_need_create_in_switch(t, screen_context.an_current) == wa_ok)
		{
			screen_context.dst->create();
			wa_screen_dst_prepare_before_anim();
		}
		screen_context.an_current++;
	}
}

/**
* set the anim timeline
* @param type
* @param time long
*/
static void wa_screen_set_anim_timeline(wa_screen_switch_type type, uint32_t time_long)
{
	uint8_t i;
	uint8_t anim_cnt;
	anim_cnt = wa_screen_get_anim_cnt(type);
	for (i = 0; i < anim_cnt; i++)
	{
		screen_context.an_switch[i] = wa_anim_create();
		wa_anim_set_exec_cb(screen_context.an_switch[i], wa_screen_switch_exec_cb);
		wa_anim_set_finish_cb(screen_context.an_switch[i], (wa_anim_finish_cb)wa_screen_switch_finish_cb);
		wa_anim_set_path_cb(screen_context.an_switch[i], wa_anim_path_ease_in_out);
		wa_anim_set_var(screen_context.an_switch[i], screen_context.an_switch[i]);
		wa_anim_set_early_apply(screen_context.an_switch[i], wa_ok);
	}
	for (i = 0; i < anim_cnt; i++)
	{
		wa_anim_set_time_long(screen_context.an_switch[i], time_long / anim_cnt);
		wa_anim_timeline_dsc_init(&screen_context.ad_switch[i], screen_context.an_switch[i], i * (time_long / anim_cnt));
	}
	wa_anim_timeline_init(&screen_context.at_swicth, screen_context.ad_switch, anim_cnt);
	wa_screen_switch_set_anim_value(type);
}

/**
*save and set hmi before switch
*/
static void wa_screen_save_hmi_before_swtich(void)
{
	screen_context.pid = wa_pid_is_enable();
	if (screen_context.pid == wa_ok)
	{
		wa_pid_enable(wa_nok);
	}
	screen_context.input = wa_input_is_enable();
	if (screen_context.input == wa_ok)
	{
		wa_input_enable(wa_nok);
	}
}

/**
*recover and set something after switch
*/
static void wa_screen_recover_hmi_after_swtich(void)
{
	if (screen_context.pid == wa_ok)
	{
		wa_pid_enable(wa_ok);
	}
	if (screen_context.input == wa_ok)
	{
		wa_input_enable(wa_ok);
	}
}

/**
*all switch anim set value func and exec_cb func
*/
/***********************************************************************************************/
static void blinds_hor_set_value(void)
{
	wa_screen_switch_context* sm = &screen_context;
	wa_screen_erase_set_unit_size(sm->scr_erase, WA_LCD_W, 8);
	wa_screen_erase_set_func(sm->scr_erase, wa_screen_erase_func_blinds_horizontal);
	wa_anim_set_values(sm->an_switch[0], 0, 1000);
	wa_anim_set_values(sm->an_switch[1], 1000, 0);
}
static void blinds_hor_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	if (anim_num == anim_array)
	{
		wa_screen_erase_set_erase_rate(screen_context.scr_erase, value);
		wa_screen_erase_update(screen_context.scr_erase);
	}
}
/***********************************************************************************************/
static void blinds_ver_set_value(void)
{
	wa_screen_switch_context* sm = &screen_context;
	wa_screen_erase_set_unit_size(sm->scr_erase, 8, WA_LCD_W);
	wa_screen_erase_set_func(sm->scr_erase, wa_screen_erase_func_blinds_vertical);
	wa_anim_set_values(sm->an_switch[0], 0, 1000);
	wa_anim_set_values(sm->an_switch[1], 1000, 0);
}
static void blinds_ver_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	if (anim_num == anim_array)
	{
		wa_screen_erase_set_erase_rate(screen_context.scr_erase, value);
		wa_screen_erase_update(screen_context.scr_erase);
	}
}
/***********************************************************************************************/
static void boxs_hor_set_value(void)
{
	wa_screen_switch_context* sm = &screen_context;
	wa_screen_erase_set_unit_size(sm->scr_erase, 8, 8);
	wa_screen_erase_set_func(sm->scr_erase, wa_screen_erase_func_blinds_horizontal);
	wa_anim_set_values(sm->an_switch[0], 0, 1000);
	wa_anim_set_values(sm->an_switch[1], 1000, 0);
}
static void boxs_hor_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	if (anim_num == anim_array)
	{
		wa_screen_erase_set_erase_rate(screen_context.scr_erase, value);
		wa_screen_erase_update(screen_context.scr_erase);
	}
}
/***********************************************************************************************/
static void boxs_ver_set_value(void)
{
	wa_screen_switch_context* sm = &screen_context;
	wa_screen_erase_set_unit_size(sm->scr_erase, 8, 8);
	wa_screen_erase_set_func(sm->scr_erase, wa_screen_erase_func_blinds_vertical);
	wa_anim_set_values(sm->an_switch[0], 0, 1000);
	wa_anim_set_values(sm->an_switch[1], 1000, 0);
}
static void boxs_ver_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	if (anim_num == anim_array)
	{
		wa_screen_erase_set_erase_rate(screen_context.scr_erase, value);
		wa_screen_erase_update(screen_context.scr_erase);
	}
}
/***********************************************************************************************/
static void top_move_enter_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], 0 - screen_context.dh, screen_context.dy);
}
static void top_move_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	wa_win_set_pos(screen_context.dst->win, screen_context.dx, value);
}
/***********************************************************************************************/
static void bottom_move_enter_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], WA_LCD_H, screen_context.dy);
}
static void bottom_move_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	wa_win_set_pos(screen_context.dst->win, screen_context.dx, value);
}
/***********************************************************************************************/
static void left_move_enter_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], 0 - screen_context.dw, screen_context.dx);
}
static void left_move_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	wa_win_set_pos(screen_context.dst->win, value, screen_context.dy);
}
/***********************************************************************************************/
static void right_move_enter_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], WA_LCD_W, screen_context.dx);
}
static void right_move_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	wa_win_set_pos(screen_context.dst->win, value, screen_context.dy);
}
/***********************************************************************************************/
static void top_move_quit_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], screen_context.sy, 0 - screen_context.sh);
}
static void top_move_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	wa_win_set_pos(screen_context.src->win, screen_context.sx, value);
}
/***********************************************************************************************/
static void bottom_move_quit_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], screen_context.sy, WA_LCD_H);
}
static void bottom_move_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	wa_win_set_pos(screen_context.src->win, screen_context.sx, value);
}
/***********************************************************************************************/
static void left_move_quit_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], screen_context.sx, 0 - screen_context.sw);
}
static void left_move_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	wa_win_set_pos(screen_context.src->win, value, screen_context.sy);
}
/***********************************************************************************************/
static void right_move_quit_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], screen_context.sx, WA_LCD_W);
}
static void right_move_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	wa_win_set_pos(screen_context.src->win, value, screen_context.sy);
}
/***********************************************************************************************/
static void top_size_enter_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], 0, screen_context.dh);
}
static void top_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	wa_win_set_pos(screen_context.dst->win, screen_context.dx, screen_context.dy);
	wa_win_set_size(screen_context.dst->win, screen_context.dw, value);
}
/***********************************************************************************************/
static void left_size_enter_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], 0, screen_context.dw);
}
static void left_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	wa_win_set_pos(screen_context.dst->win, screen_context.dx, screen_context.dy);
	wa_win_set_size(screen_context.dst->win, value, screen_context.dh);
}
/***********************************************************************************************/
static void top_left_size_enter_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], 0, screen_context.dh);
}
static void top_left_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	wa_win_set_pos(screen_context.dst->win, screen_context.dx, screen_context.dy);
	wa_win_set_size(screen_context.dst->win, value * screen_context.dw / screen_context.dh, value);
}
/***********************************************************************************************/
static void top_size_quit_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], screen_context.sh, 0);
}
static void top_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	wa_win_set_pos(screen_context.src->win, screen_context.sx, screen_context.sy);
	wa_win_set_size(screen_context.src->win, screen_context.sw, value);
}
/***********************************************************************************************/
static void left_size_quit_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], screen_context.sw, 0);
}
static void left_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	wa_win_set_pos(screen_context.src->win, screen_context.sx, screen_context.sy);
	wa_win_set_size(screen_context.src->win, value, screen_context.sh);
}
/***********************************************************************************************/
static void top_left_size_quit_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], screen_context.sh, 0);
}
static void top_left_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	wa_win_set_pos(screen_context.src->win, screen_context.sx, screen_context.sy);
	wa_win_set_size(screen_context.src->win, value * screen_context.sw / screen_context.sh, value);
}
/***********************************************************************************************/
static void bottom_size_enter_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], 0, screen_context.dh);
}
static void bottom_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	wa_win_set_pos(screen_context.dst->win, screen_context.dx, screen_context.dy + screen_context.dh - value);
	wa_win_set_size(screen_context.dst->win, screen_context.dw, value);
	wa_win_set_panel_rel_pos(screen_context.dst->win, 0, value - screen_context.dh);
	wa_win_set_panel_rel_size(screen_context.dst->win, 0, screen_context.dh - value);
}
/***********************************************************************************************/
static void right_size_enter_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], 0, screen_context.dw);
}
static void right_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	wa_win_set_pos(screen_context.dst->win, screen_context.dx + screen_context.dw - value, screen_context.dy);
	wa_win_set_size(screen_context.dst->win, value, screen_context.dh);
	wa_win_set_panel_rel_pos(screen_context.dst->win, value - screen_context.dw, 0);
	wa_win_set_panel_rel_size(screen_context.dst->win, screen_context.dw - value, 0);
}
/***********************************************************************************************/
static void bottom_size_quit_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], screen_context.sh, 0);
}
static void bottom_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	wa_win_set_pos(screen_context.src->win, screen_context.sx, screen_context.sy + screen_context.sh - value);
	wa_win_set_size(screen_context.src->win, screen_context.sw, value);
	wa_win_set_panel_rel_pos(screen_context.src->win, 0, value - screen_context.sh);
	wa_win_set_panel_rel_size(screen_context.src->win, 0, screen_context.sh - value);
}
/***********************************************************************************************/
static void right_size_quit_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], screen_context.sw, 0);
}
static void right_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	wa_win_set_pos(screen_context.src->win, screen_context.sx + screen_context.sw - value, screen_context.sy);
	wa_win_set_size(screen_context.src->win, value, screen_context.sh);
	wa_win_set_panel_rel_pos(screen_context.src->win, value - screen_context.sw, 0);
	wa_win_set_panel_rel_size(screen_context.src->win, screen_context.sw - value, 0);
}
/***********************************************************************************************/
static void top_right_size_enter_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], 0, screen_context.dh);
}
static void top_right_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	int32_t valr = value * screen_context.dw / screen_context.dh;
	wa_win_set_pos(screen_context.dst->win, screen_context.dx + screen_context.dw - valr, screen_context.dy);
	wa_win_set_size(screen_context.dst->win, valr, value);
	wa_win_set_panel_rel_pos(screen_context.dst->win, valr - screen_context.dw, 0);
	wa_win_set_panel_rel_size(screen_context.dst->win, screen_context.dw - valr, screen_context.dh - value);
}
/***********************************************************************************************/
static void bottom_left_size_enter_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], 0, screen_context.dh);
}
static void bottom_left_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	int32_t valr = value * screen_context.dw / screen_context.dh;
	wa_win_set_pos(screen_context.dst->win, screen_context.dx, screen_context.dy + screen_context.dh - value);
	wa_win_set_size(screen_context.dst->win, valr, value);
	wa_win_set_panel_rel_pos(screen_context.dst->win, 0, value - screen_context.dh);
	wa_win_set_panel_rel_size(screen_context.dst->win, screen_context.dw - valr, screen_context.dh - value);
}
/***********************************************************************************************/
static void bottom_right_size_enter_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], 0, screen_context.dh);
}
static void bottom_right_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	int32_t valr = value * screen_context.dw / screen_context.dh;
	wa_win_set_pos(screen_context.dst->win, screen_context.dx + screen_context.dw - valr, screen_context.dy + screen_context.dh - value);
	wa_win_set_size(screen_context.dst->win, valr, value);
	wa_win_set_panel_rel_pos(screen_context.dst->win, valr - screen_context.dw, value - screen_context.dh);
	wa_win_set_panel_rel_size(screen_context.dst->win, screen_context.dw - valr, screen_context.dh - value);
}
/***********************************************************************************************/
static void top_right_size_quit_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], screen_context.sh, 0);
}
static void top_right_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	int32_t valr = value * screen_context.sw / screen_context.sh;
	wa_win_set_pos(screen_context.src->win, screen_context.sx + screen_context.sw - valr, screen_context.sy);
	wa_win_set_size(screen_context.src->win, valr, value);
	wa_win_set_panel_rel_pos(screen_context.src->win, valr - screen_context.sw, 0);
	wa_win_set_panel_rel_size(screen_context.src->win, screen_context.sw - valr, screen_context.sh - value);
}
/***********************************************************************************************/
static void bottom_left_size_quit_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], screen_context.sh, 0);
}
static void bottom_left_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	int32_t valr = value * screen_context.sw / screen_context.sh;
	wa_win_set_pos(screen_context.src->win, screen_context.sx, screen_context.sy + screen_context.sh - value);
	wa_win_set_size(screen_context.src->win, valr, value);
	wa_win_set_panel_rel_pos(screen_context.src->win, 0, value - screen_context.sh);
	wa_win_set_panel_rel_size(screen_context.src->win, screen_context.sw - valr, screen_context.sh - value);
}
/***********************************************************************************************/
static void bottom_right_size_quit_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], screen_context.sh, 0);
}
static void bottom_right_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	int32_t valr = value * screen_context.sw / screen_context.sh;
	wa_win_set_pos(screen_context.src->win, screen_context.sx + screen_context.sw - valr, screen_context.sy + screen_context.sh - value);
	wa_win_set_size(screen_context.src->win, valr, value);
	wa_win_set_panel_rel_pos(screen_context.src->win, valr - screen_context.sw, value - screen_context.sh);
	wa_win_set_panel_rel_size(screen_context.src->win, screen_context.sw - valr, screen_context.sh - value);
}
/***********************************************************************************************/
static void center_size_enter_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], 0, screen_context.dh);
}
static void center_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	int32_t valr = value * screen_context.dw / screen_context.dh;
	wa_win_set_pos(screen_context.dst->win, screen_context.dx + (screen_context.dw - valr) / 2, screen_context.dy + (screen_context.dh - value) / 2);
	wa_win_set_size(screen_context.dst->win, valr, value);
	wa_win_set_panel_rel_pos(screen_context.dst->win, (valr - screen_context.dw) / 2, (value - screen_context.dh) / 2);
	wa_win_set_panel_rel_size(screen_context.dst->win, screen_context.dw - valr, screen_context.dh - value);
}
/***********************************************************************************************/
static void center_size_quit_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], screen_context.sh, 0);
}
static void center_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	int32_t valr = value * screen_context.dw / screen_context.dh;
	wa_win_set_pos(screen_context.src->win, screen_context.sx + (screen_context.sw - valr) / 2, screen_context.sy + (screen_context.sh - value) / 2);
	wa_win_set_size(screen_context.src->win, valr, value);
	wa_win_set_panel_rel_pos(screen_context.src->win, (valr - screen_context.sw) / 2, (value - screen_context.sh) / 2);
	wa_win_set_panel_rel_size(screen_context.src->win, screen_context.sw - valr, screen_context.sh - value);
}
/***********************************************************************************************/
static void center_hv_size_enter_set_value(void)
{
	wa_win_ext* ext;
	wa_anim_set_values(screen_context.an_switch[0], 0, screen_context.dw);
	ext = wa_obj_get_ext_attr(screen_context.dst->win);
	wa_anim_set_values(screen_context.an_switch[1], ext->edge_size * 2, screen_context.dh);
}
static void center_hv_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	if (anim_num != anim_array)
	{
		return;
	}
	if (anim_num == 0)
	{
		wa_win_ext* ext;
		ext = wa_obj_get_ext_attr(screen_context.dst->win);
		wa_win_set_pos(screen_context.dst->win, screen_context.dx + (screen_context.dw - value) / 2, screen_context.dy + (screen_context.dh - ext->edge_size * 2) / 2);
		wa_win_set_size(screen_context.dst->win, value, ext->edge_size * 2);
		wa_win_set_panel_rel_pos(screen_context.dst->win, (value - screen_context.dw) / 2, (ext->edge_size * 2 - screen_context.dh) / 2);
		wa_win_set_panel_rel_size(screen_context.dst->win, screen_context.dw - value, screen_context.dh - ext->edge_size * 2);
	}
	else if (anim_num == 1)
	{
		wa_win_set_pos(screen_context.dst->win, screen_context.dx, screen_context.dy + (screen_context.dh - value) / 2);
		wa_win_set_size(screen_context.dst->win, screen_context.dw, value);
		wa_win_set_panel_rel_pos(screen_context.dst->win, 0, (value - screen_context.dh) / 2);
		wa_win_set_panel_rel_size(screen_context.dst->win, 0, screen_context.dh - value);
	}
}
/***********************************************************************************************/
static void center_vh_size_enter_set_value(void)
{
	wa_win_ext* ext;
	ext = wa_obj_get_ext_attr(screen_context.dst->win);
	wa_anim_set_values(screen_context.an_switch[0], 0, screen_context.dh);
	wa_anim_set_values(screen_context.an_switch[1], ext->edge_size * 2, screen_context.dw);
}
static void center_vh_size_enter_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	if (anim_num != anim_array)
	{
		return;
	}
	if (anim_num == 0)
	{
		wa_win_ext* ext;
		ext = wa_obj_get_ext_attr(screen_context.dst->win);
		wa_win_set_pos(screen_context.dst->win, screen_context.dx + (screen_context.dw - ext->edge_size * 2) / 2, screen_context.dy + (screen_context.dh - value) / 2);
		wa_win_set_size(screen_context.dst->win, ext->edge_size * 2, value);
		wa_win_set_panel_rel_pos(screen_context.dst->win, (ext->edge_size * 2 - screen_context.dw) / 2, (value - screen_context.dh) / 2);
		wa_win_set_panel_rel_size(screen_context.dst->win, screen_context.dw - ext->edge_size * 2, screen_context.dh - value);
	}
	else if (anim_num == 1)
	{
		wa_win_set_pos(screen_context.dst->win, screen_context.dx + (screen_context.dw - value) / 2, screen_context.dy);
		wa_win_set_size(screen_context.dst->win, value, screen_context.dh);
		wa_win_set_panel_rel_pos(screen_context.dst->win, (value - screen_context.dw) / 2, 0);
		wa_win_set_panel_rel_size(screen_context.dst->win, screen_context.dw - value, 0);
	}
}
/***********************************************************************************************/
static void center_hv_size_quit_set_value(void)
{
	wa_win_ext* ext;
	ext = wa_obj_get_ext_attr(screen_context.src->win);
	wa_anim_set_values(screen_context.an_switch[0], screen_context.sh, ext->edge_size * 2);
	wa_anim_set_values(screen_context.an_switch[1], screen_context.sw, 0);
}
static void center_hv_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	if (anim_num != anim_array)
	{
		return;
	}
	if (anim_num == 0)
	{
		wa_win_set_pos(screen_context.src->win, screen_context.sx, screen_context.sy + (screen_context.sh - value) / 2);
		wa_win_set_size(screen_context.src->win, screen_context.sw, value);
		wa_win_set_panel_rel_pos(screen_context.src->win, 0, (value - screen_context.sh) / 2);
		wa_win_set_panel_rel_size(screen_context.src->win, 0, screen_context.sh - value);
	}
	else if (anim_num == 1)
	{
		wa_win_ext* ext;
		ext = wa_obj_get_ext_attr(screen_context.src->win);
		wa_win_set_pos(screen_context.src->win, screen_context.sx + (screen_context.sw - value) / 2, screen_context.sy + (screen_context.sh - ext->edge_size * 2) / 2);
		wa_win_set_size(screen_context.src->win, value, ext->edge_size * 2);
		wa_win_set_panel_rel_pos(screen_context.src->win, (value - screen_context.sw) / 2, (ext->edge_size * 2 - screen_context.sh) / 2);
		wa_win_set_panel_rel_size(screen_context.src->win, screen_context.sw - value, screen_context.sh - ext->edge_size * 2);
	}
}
/***********************************************************************************************/
static void center_vh_size_quit_set_value(void)
{
	wa_win_ext* ext;
	ext = wa_obj_get_ext_attr(screen_context.src->win);
	wa_anim_set_values(screen_context.an_switch[0], screen_context.sw, ext->edge_size * 2);
	wa_anim_set_values(screen_context.an_switch[1], screen_context.sh, 0);
}
static void center_vh_size_quit_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	if (anim_num != anim_array)
	{
		return;
	}
	if (anim_num == 0)
	{
		wa_win_set_pos(screen_context.src->win, screen_context.sx + (screen_context.sw - value) / 2, screen_context.sy);
		wa_win_set_size(screen_context.src->win, value, screen_context.sh);
		wa_win_set_panel_rel_pos(screen_context.src->win, (value - screen_context.sw) / 2, 0);
		wa_win_set_panel_rel_size(screen_context.src->win, screen_context.sw - value, 0);
	}
	else if (anim_num == 1)
	{
		wa_win_ext* ext;
		ext = wa_obj_get_ext_attr(screen_context.src->win);
		wa_win_set_pos(screen_context.src->win, screen_context.sx + (screen_context.sw - ext->edge_size * 2) / 2, screen_context.sy + (screen_context.sh - value) / 2);
		wa_win_set_size(screen_context.src->win, ext->edge_size * 2, value);
		wa_win_set_panel_rel_pos(screen_context.src->win, (ext->edge_size * 2 - screen_context.sw) / 2, (value - screen_context.sh) / 2);
		wa_win_set_panel_rel_size(screen_context.src->win, screen_context.sw - ext->edge_size * 2, screen_context.sh - value);
	}
}
/***********************************************************************************************/
static void top_together_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], 0 - screen_context.dh, screen_context.dy);
}
static void top_together_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	int32_t valr = WA_LCD_H - ((screen_context.dy - value) * (WA_LCD_H - screen_context.sy) / (screen_context.dh + screen_context.dy));
	wa_win_set_pos(screen_context.dst->win, screen_context.dx, value);
	wa_win_set_pos(screen_context.src->win, screen_context.sx, valr);
}
/***********************************************************************************************/
static void bottom_together_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], WA_LCD_H, screen_context.dy);
}
static void bottom_together_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	int32_t valr = -screen_context.sh - ((screen_context.dy - value) * (screen_context.sh + screen_context.sy) / (WA_LCD_H - screen_context.dy));
	wa_win_set_pos(screen_context.dst->win, screen_context.dx, value);
	wa_win_set_pos(screen_context.src->win, screen_context.sx, valr);
}
/***********************************************************************************************/
static void left_together_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], 0 - screen_context.dw, screen_context.dx);
}
static void left_together_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	int32_t valr = WA_LCD_W - ((screen_context.dx - value) * (WA_LCD_W - screen_context.sx) / (screen_context.dw + screen_context.dx));
	wa_win_set_pos(screen_context.dst->win, value, screen_context.dy);
	wa_win_set_pos(screen_context.src->win, valr, screen_context.sy);
}
/***********************************************************************************************/
static void right_together_set_value(void)
{
	wa_anim_set_values(screen_context.an_switch[0], WA_LCD_W, screen_context.dx);
}
static void right_together_exec_cb(uint8_t anim_num, uint8_t anim_array, int32_t value)
{
	int32_t valr = -screen_context.sw - ((screen_context.dx - value) * (screen_context.sw + screen_context.sx) / (WA_LCD_W - screen_context.dx));
	wa_win_set_pos(screen_context.dst->win, value, screen_context.dy);
	wa_win_set_pos(screen_context.src->win, valr, screen_context.sy);
}
/***********************************************************************************************/


#endif
#endif
